{include file="header.html"}
<div id="rightTop">
  <p>小程序码</p>
  <ul class="subnav">
  </ul>
</div>
<div class="info">
  <form method="post">
    <table class="infoTable">
      <tr>
        <th class="paddingT15">小程序码:</th>
        <td class="paddingT15 wordSpacing5">
            <!--{if $goodsInfo.applet_code neq ''}-->
            <img src="{$goodsInfo.applet_code}" class="makesmall" max_width="120" max_height="90" />
            <!--{else}-->
            <a class="btn1" href="javascript:;" id="get_applet_code" data-goodsId="{$goodsInfo.goods_id}">获取小程序码</a>
            <!--{/if}-->
        </td>
      </tr>
      <script type="text/javascript" src="{res file=js/jslang.js}"></script>
      <tr>
        <th class="paddingT15">小程序页面地址</th>
        <td class="paddingT15 wordSpacing5"><p>
            <font id="html">pages/product/detail?goods_id={$goodsInfo.goods_id}</font>
            <a class="btn1" href="javascript:;" id="copy">复制到剪贴板</a>
        </p>
        </td>
      </tr>
        <tr>
            <th></th>
            <td class="ptb20"><input type="hidden" name="id" value="{$smarty.get.id}" />
                <input class="formbtn" type="button" value="{$lang.back}" onclick="history.go(-1)" />
            </td>
        </tr>
    </table>
  </form>
</div>
{include file="footer.html"}
<script src="//cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/layer/2.3/layer.js"></script>
<script>
    $("#get_applet_code").click(function(){
        var url = "index.php?app=goods&act=getAppletCode";
        var goods_id = $(this).attr("data-goodsId");
        if(goods_id == ''){
            layer.msg('参数错误');
            return false;
        }
        var index = layer.load(0, {
            shade: false
        }); //0代表加载
        $.post(url,{
            goods_id:goods_id
        },function(data){
            layer.closeAll('loading');
            var res = JSON.parse(data);
            layer.msg(res.msg,function(){
                window.location.reload();
            });
        })

    })

    $("#copy").click(function(){
        // //复制功能
        var copyBtn = document.querySelector('.copy');
        var html = $("#html").html();
        var oInput = document.createElement('input');
        oInput.value = html;
        document.body.appendChild(oInput);
        selectText(oInput)
        document.execCommand("Copy");
        oInput.className = 'oInput';
        oInput.style.display = 'none';
        alert('复制成功！');

    })
    function selectText(oInput) {
        if(oInput.createTextRange) {//ie
            oInput.select();
        }else{//firefox/chrome
            oInput.setSelectionRange(0, oInput.value.length);
            oInput.focus();
        }
    }
</script>